package com.ruoyi.business.controller;

import com.ruoyi.business.domain.RackParam;
import com.ruoyi.business.service.IRackParamService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 台架参数Controller
 * 
 * @author qiancheng
 * @date 2025-06-23
 */
@Api(tags = "台架参数管理")
@RestController
@RequestMapping("/business/param")
public class RackParamController extends BaseController
{
    @Autowired
    private IRackParamService rackParamService;

    /**
     * 查询台架参数列表
     */
    @ApiOperation("查询台架参数列表")
    @PreAuthorize("@ss.hasPermi('business:param:list')")
    @GetMapping("/list")
    public TableDataInfo list(@ApiParam("台架参数查询条件") RackParam rackParam)
    {
        startPage();
        List<RackParam> list = rackParamService.selectRackParamList(rackParam);
        return getDataTable(list);
    }

    /**
     * 导出台架参数列表
     */
    @ApiOperation("导出台架参数列表")
    @PreAuthorize("@ss.hasPermi('business:param:export')")
    @Log(title = "台架参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @ApiParam("台架参数查询条件") RackParam rackParam)
    {
        List<RackParam> list = rackParamService.selectRackParamList(rackParam);
        ExcelUtil<RackParam> util = new ExcelUtil<RackParam>(RackParam.class);
        util.exportExcel(response, list, "台架参数数据");
    }

    /**
     * 获取台架参数详细信息
     */
    @ApiOperation("获取台架参数详细信息")
    @PreAuthorize("@ss.hasPermi('business:param:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam("参数ID") @PathVariable("id") Long id)
    {
        return success(rackParamService.selectRackParamById(id));
    }

    /**
     * 新增台架参数
     */
    @ApiOperation("新增台架参数")
    @PreAuthorize("@ss.hasPermi('business:param:add')")
    @Log(title = "台架参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("台架参数信息") @RequestBody RackParam rackParam)
    {
        return toAjax(rackParamService.insertRackParam(rackParam));
    }

    /**
     * 修改台架参数
     */
    @ApiOperation("修改台架参数")
    @PreAuthorize("@ss.hasPermi('business:param:edit')")
    @Log(title = "台架参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("台架参数信息") @RequestBody RackParam rackParam)
    {
        return toAjax(rackParamService.updateRackParam(rackParam));
    }

    /**
     * 删除台架参数
     */
    @ApiOperation("删除台架参数")
    @PreAuthorize("@ss.hasPermi('business:param:remove')")
    @Log(title = "台架参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("参数ID数组") @PathVariable Long[] ids)
    {
        return toAjax(rackParamService.deleteRackParamByIds(ids));
    }

    /**
     * 首页->>获取台架参数详细信息
     */
    @ApiOperation("获取台架参数详细信息用于首页")
    @Anonymous
    @GetMapping(value = "/getRackParam")
    public AjaxResult getRackParam(@ApiParam("台架参数查询条件") RackParam rackParam)
    {
        return success(rackParamService.getRackParam(rackParam));
    }

}
